#ifndef __INTERNET_COMMON_H__
#define __INTERNET_COMMON_H__


#include "esp_eth.h"
#include "esp_wifi.h"

#include "freertos/event_groups.h"
#include "gw-device.h"

#include "lwip/ip4_addr.h"

#define NET_INTERFACE_ERROR 0
#define NET_INTERFACE_WIFI  1
#define NET_INTERFACE_ETH   2
#define NET_INTERFACE_4G    3

typedef struct 
{
    uint8_t net_interface;
    ip4_addr_t ip;
    ip4_addr_t gateway;
    ip4_addr_t netmask;
}net_info_t;

EventGroupHandle_t wifi_event_group;
EventGroupHandle_t ethernet_event_group;

#define IPV4_GOTIP_BIT BIT0
#define IPV6_GOTIP_BIT BIT1


void internet_common_init(void);
bool isWIfiConnected(void);
bool isEthernetConnected(void);

bool connect_to_network(config_para_t* device_settings);
bool connect_without_init(config_para_t* device_settings);
// bool reconnect_to_network(config_para_t* device_settings);

void set_net_info(net_info_t* src);
void get_net_info(net_info_t* dest);
void reset_net_info();
uint8_t get_interface_type();

void printf_net_info();



#endif
